package com.wangshili.test.aop.annotation;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class SysCacheAspect {
	private static final Logger log = 
			LoggerFactory.getLogger(SysCacheAspect .class);
	//使用注解的方式进行切面，匹配所有加了这个注解的方法
	@Pointcut("@annotation(com.wangshili.test.aop.annotation.RequiredCache)")
	public void requiredCache() {}
	
	@Around("requiredCache()")
	public Object annotationAspect(ProceedingJoinPoint  jc) throws Throwable {
		try {
			log.debug("注解切面:{}",jc.getSignature().getName());
			Object proceed = jc.proceed();
			return proceed;
		} catch (Exception e) {
			throw e;
		}
		
	}
}
